package csc411;

public class Rates {

	private final static float USD = 1f;
	private final static float SGD = 1.39340f;

	private static float get(Currency type) {

		float value = 0;

		if (type == Currency.SGD) {
			value = Rates.SGD;
		}

		if (type == Currency.USD) {
			value = Rates.USD;
		}

		return value;
	}

	public static float convert(float amount, Currency from, Currency to) {
		float value = 0;

		if (from != to) {

			// for more than 2 currency rates, convert original amount to USD,
			// then USD to target Currency
			// but here, we only have 2 currency rates.

			value = amount * Rates.get(to) / Rates.get(from);

		} else {
			value = amount;
		}

		return value;
	}
}
